package com.lzm.ydpt.wxapi;

import android.content.Intent;
import android.os.Build;

import com.byt.framlib.commonutils.ToastUitl;
import com.lzm.ydpt.module.mall.activity.PayOrderActivity;
import com.tencent.mm.opensdk.modelbase.BaseResp;

/**
 * 支付成功后的回调
 *
 * @description：
 * @date 2015年6月6日 上午11:08:37
 */
public class WXPayEntryActivity extends WXPayEntryActBase {
    public static int WXYUANSHENGPEI = -1;
    public static int PAYTYPE = 0; // 0服务购买 1商城支付 2 稿子购买
    public static final String INP_WX_PAY_TYPE = "WX_PAY_TYPE";
    @Override
    public void paySuccess(BaseResp resp) {
        if (isOPPO()) {
            WXYUANSHENGPEI = 1;
        } else {
            switch (PAYTYPE) {
                case 0:
                    break;
                case 1:
                    Intent orderIntent = new Intent(this, PayOrderActivity.class);
                    orderIntent.putExtra(INP_WX_PAY_TYPE, 1);
                    startActivity(orderIntent);
                    break;
                case 2:
                    break;
            }

        }
        finish();
    }

    @Override
    public void payFail(BaseResp resp) {
        if (isOPPO()) {
            WXYUANSHENGPEI = 0;
        } else {
            switch (PAYTYPE) {
                case 0:
                    break;
                case 1:
                    Intent orderIntent = new Intent(this, PayOrderActivity.class);
                    orderIntent.putExtra(INP_WX_PAY_TYPE, 0);
                    startActivity(orderIntent);
                    break;
                case 2:
                    break;
            }
        }
        finish();
    }

    @Override
    public void payCancle(BaseResp resp) {
        if (isOPPO()) {
            WXYUANSHENGPEI = -1;
            ToastUitl.showShort("您取消了支付操作！");
        } else {
            ToastUitl.showShort("您取消了支付操作！");
        }
        finish();
    }

    private boolean isOPPO() {
        String manufacturer = Build.MANUFACTURER;
        return "OPPO".equalsIgnoreCase(manufacturer);
    }
}